<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
<title> 我的Wishlist - LooPo-乐铺 </title>
<?php include VIEWS.'header.html'?>

<script language="JavaScript">
<!--
var aa = ajaxStart();
var timer = null;

function wishaddress() {
    $('submit').disabled = true;
    var f = $('updateform');

    $('updatemsg').hide(); $('loading').show();

    try {
        aa.call('/myWishList.php', 'ajaxuserWishListAddress', wishaddress_result, $('updateform').serialize());
        return false;
    } catch (e) {
        return true;
    }
}

function wishaddress_result(result) {
    var i;
    var d = $('updatemsg');
    try {
        var stat = result.result[0].data;
        if (stat==1)    i = '您的送达地址已更新';
        if (stat&4)     i = '请填写完整的地址信息';
    } catch(e) {
        var err = 1;
        i = '服务器错误，请稍候再试';
    }

    if (stat&4 || err) {
        d.style.backgroundColor= '#FF6600';
        d.style.color = '#FFF';
    } else {
        try{$('erraddr').hide();}catch(e){}
        d.style.backgroundColor= '#DDF63E';
        d.style.color = '#000';
    }

    $('submit').disabled = false;
    d.innerHTML = '&nbsp;&nbsp;&nbsp;' + i + '……';

    $('loading').hide(); $('updatemsg').show();
    
    new Effect.Round('div', 'updatemsg');
    if (timer) window.clearTimeout(timer);
    setTimeout( "$('updatemsg').style.display='none';", 20000);
}

function removewish(id) {
    $('w'+id).remove();
    try {
        $('submit').disabled = true;
        $('submita').disabled = true;
    } catch(e) {}
    var f = $('updateform');

    $('updatemsg').hide(); $('loading').show();

    aa.call('/myWishList.php/remove/'+id, 'ajaxuserWishRemove', removewish_result, "remove="+id);
    return false;
}

function removewish_result(result) { 
    $('loading').hide();
    tojs();
}

function tojs() {
    $('c_preview').innerHTML = '<b>Loading...</b>';
    var num = $F('c_num') > 50 ? 50 : $F('c_num') ? $F('c_num') : 5;
    var sort = $('r1').checked ? 'date' : $('r5').checked ? 'rand' : 'price';
    var od = $('r3').checked ? 'desc' : 'asc';

    var js = '<script type="text/javascript" src="';
    js += 'http://www.loopo.cn/wishlist/js/<?php echo urlencode($session['username'])?>?';
    var qstr = 'num=' + num;
    qstr += '&sort=' + sort;
    if (sort!='rand') qstr += '&od=' + od;
    if ($('c_price').checked) qstr += '&price=1';
    js   += qstr + '"></'+'script>';

    $('c_js').value = js;

    //preview
    try {new Ajax.Updater('c_preview', '/wishlist/js/<?php echo urlencode($session['username'])?>', {method: 'get', parameters:qstr+'&preview=1', evalScripts:true});} catch (e) {alert('效果预览失败')}
}
//-->
</script>

</head>

<body>

<?php include VIEWS.'topbar.html'?>

<div id="content">

    <?php include VIEWS.'leftnav.html'?>

<div id="right">
<h1>我的Wishlist</h1>

<?php if(!$data['truename'] || !$data['tel'] || !$data['address'] || !$data['zipcode']):?>
<div id="erraddr" class="errbox roundNormal" style="width:90%">&nbsp;&nbsp;&nbsp;乐铺提醒您：请尽快补充完整您的礼品送达地址，以免出现收不到礼品的情况。</div><br />
<?php endif?>

<?php $tips_drop_hide=true; include VIEWS.'shopcarinfo.html'?>

<h3 style="margin-bottom:5px"><img src="/images/icon_arrow_down.gif" />物品列表</h3>
<hr size="1" />
<?php if(!count($list['list'])):?>
<div class="errbox roundNormal" style="width:90%">&nbsp;&nbsp;&nbsp;您目前的 Wishlist 为空</div>
<?php else:?>
<ul>
<table width="90%" cellpadding="2">
<?php foreach($list['list'] as $v):?>
<tr id="w<?php echo $v['id']?>"><td><li class="px12"><a href="/items/<?php echo $v['id']?>" target="_blank"><?php echo $v['name']?></a></li></td><td class="px12"><b><?php echo '&yen; '.str_replace('.00', '.-', $v['price1'])?></b></td><td><a class="px12" onclick="javascript:addtocar(<?php echo $v['id']?>);return false;" href="/addtocar/<?php echo $v['id']?>">加入购物车</a>　&nbsp;<a onclick="javascript:return removewish(<?php echo $v['id']?>)" class="px12" href="/myWishList/remove/<?php echo $v['id']?>">移除</a></td></tr>
<?php endforeach?>
</table>
</ul>
<div style="float:right;padding-right:2em" class="px12">
<?php if($list['page']['perv']):?>&nbsp;&nbsp;<a tabindex="5" href=<?php echo $list['page']['url']?>p=<?php echo $list['page']['perv']?>>上一页</a>&nbsp;<?php endif;?>
<?php if($list['page']['next']):?>&nbsp;&nbsp;<a tabindex="5" href=<?php echo $list['page']['url']?>p=<?php echo $list['page']['next']?>>下一页</a><?php endif;?></div>
<?php endif?>

<br /><br />

<h3 style="margin:0"><img id="rightarrow" src="/images/icon_arrow_down.gif" />地址信息</h3>
<hr size="1" />
<div id="loading" style="display:none;padding-left:1em"><img src="/images/icon_indicator.gif" width="220" height="19" alt=""  /></div>
<div class="updatemsg" id="updatemsg" style="font-weight:bold;background-color:#DDF63E;font-size:12px;width:60%;display:none;">&nbsp;</div><br clear="all" />
<p style="text-indent:0;margin:0;margin-left:2em" class="px12"><b>请保证您下列收货信息是可送达的</b>，以免出现礼品无法送达的情况。</p>
<br clear="all">

<form action="" method="post" id="updateform" onsubmit="javascript:return wishaddress();">
<table cellpadding="2" width="98%" cellspacing="2" border="0" style="margin-left:1em">
<tr><td class="px12"><b>真实姓名</b></td><td class="px12"><input class="px12" tabindex="1" maxlength="20" size="10" type="text" name="truename" value="<?php echo $data['truename']?>"></td></tr>
<tr><td class="px12"><b>联系电话</b></td><td class="px12"><input class="px12" tabindex="1" maxlength="20" size="10" type="text" name="tel" value="<?php echo $data['tel']?>"></td></tr>
<tr><td class="px12"><b>送达地址</b></td><td class="px12"><input class="px12" tabindex="1" maxlength="200" size="40" type="text" name="address" value="<?php echo $data['address']?>"></td></tr>
<tr><td class="px12"><b>邮编</b></td><td class="px12"><input class="px12" tabindex="1" maxlength="10" size="10" type="text" name="zipcode" value="<?php echo $data['zipcode']?>"></td></tr>
</table>
<br />
<input style="margin-left:2em" tabindex="2" id="submit" type="submit" value="更新地址" class="bluebtn" />
</form>


<br /><br />

<h3 style="margin:0"><img id="rightarrow" src="/images/icon_arrow_down.gif" />外部调用</h3>
<hr size="1" />
<p style="text-indent:0;margin:0;margin-left:2em" class="px12">通过设置下面的一些参数来实现从远程通过js调用你的 wishlist。<br />比如你可以把你的 wishlist 放置在你的博客或者网站上，等等……</p>
<br clear="all">

<div id="js" style="background:#EEE; width:95%; padding:.5em; margin-left:1em; text-align:center">
<h3 style="margin:.3em;float:left">调用代码</h3>
<textarea id="c_js" readonly="1" rows="3" cols="80" class="px12" onclick="this.select()">
&lt;script type="text/javascript" src="http://www.loopo.cn/wishlist/js/<?php echo urlencode($session['username'])?>?num=5&sort=date&od=desc"&gt;&lt;/script&gt;
</textarea>
</div>

<br clear="all" />

<div id="config" style="background:#EEE; width:45%; padding:.5em; float:left; margin-left:1em; line-height:200%" class="px12">
<h3 style="margin:.3em">设置</h3>
<table>
<tr><td class="px12">显示条数：</td><td class="px12"><input onkeyup="javascript:tojs();" type="text" name="num" size="1" class="px12" value="5" maxlength="2" id="c_num"> &nbsp; (最多50条)</td></tr>
<tr><td class="px12">排序：</td><td class="px12"><input type="radio" name="sort" value="update" id="r1" checked onclick="javascript:v(this.value);" /><label for="r1">按时间</label> &nbsp; <input type="radio" name="sort" value="price" id="r2" onclick="javascript:v(this.value)" /><label for="r2">按价格</label> &nbsp; <input type="radio" name="sort" value="rand" id="r5" onclick="javascript:v(this.value)" /><label for="r5">随机</label><br /><input type="radio" name="sortorder" value="desc" id="r3" checked onclick="javascript:tojs()" /><label id="v3" for="r3">从新到旧</label> &nbsp; <input type="radio" name="sortorder" value="asc" id="r4" onclick="javascript:tojs()" /><label id="v4" for="r4">从旧到新</label></td></tr>
<tr><td class="px12">显示价格：</td><td class="px12"><input type="checkbox" name="price" id="c_price" onclick="javascript:tojs();" /></td></tr>
</table>
</div>

<div id="preview" style="background:#EEE; height:110px; width:45%; padding:.5em; float:right" class="px12">
<h3 style="margin:.3em">效果</h3>
<div id="c_preview">&nbsp;</div>
</div>

    </div>
</div>

<script language="JavaScript">
<!--
function v(key) {
    tojs();
    if(key == 'rand') {
        $('r3','r4','v3','v4').invoke('hide');
    } else {
        $('r3','r4','v3','v4').invoke('show');
        if (key == 'update') {
            $('v3').innerHTML='从新到旧';$('v4').innerHTML='从旧到新';
        } else {
            $('v3').innerHTML='从高到低';$('v4').innerHTML='从低到高';
        }
    }
}

tojs();
//-->
</script>

<?php include VIEWS.'copyright.html'?>

</body>
</html>
